﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace DigibizAdvancedMediaPicker
{
    public static class DAMP_Validation
    {
        public static void ShowError(string message)
        {
            ShowError(message, string.Empty);
        }

        public static void ShowError(string message, string validationGroup)
        {
            CustomValidator cv = new CustomValidator();
            cv.IsValid = false;
            cv.ErrorMessage = message;
            if (!string.IsNullOrEmpty(validationGroup))
            {
                cv.ValidationGroup = validationGroup;
            }

            ShowError(cv);
        }

        public static void ShowError(CustomValidator cv)
        {
            Page currentPage = HttpContext.Current.Handler as Page;
            currentPage.Validators.Add(cv);
        }
    }
}